import React from 'react'
import debounce from 'lodash/debounce'

export default class ClickWrapper extends React.Component {
  static defaultProps = {
    onClick: function () { },
    style: {}
  }

  click = debounce((e) => {
    // e.preventDefault()
    const {
      onClick,
      param
    } = this.props

    onClick(param)
  }, 200)

  render() {
    const {
      className,
      children,
      param,
      ...others
    } = this.props

    return React.cloneElement(children, {
      ...others,
      onClick: this.click,
    })
  }
}
